<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 模拟获取 用户数据 订单数据 商品数据
        function getUsers() {
            setTimeout(() => {
                let data = '用户数据';
                iter.next(data);
            }, 1000)
        }
        function getOrders(users) {
            setTimeout(() => {
                console.log('getOrders-users:', users)
                let data = '订单数据';
                iter.next(data);
            }, 1000)
        }
        function getGoods(users, orders) {
            setTimeout(() => {
                console.log('getOrders-users:', users, ', getOrders-orders:', orders)
                let data = '商品数据';
                iter.next(data);
            }, 1000)
        }

        function* gen() {
            let users = yield getUsers();
            let orders = yield getOrders(users);
            let goods = yield getGoods(users, orders);
        }

        let iter = gen();
        iter.next();

    </script>
</body>
</html>